<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2024/3/21
 * Time: 11:08
 */

namespace app\controller\admin;

use app\model\admin\WebKeyword AS keyword;
class Monitor extends Base
{
    public function keyword(){
        $keyword = input('keyword.keyword');
        if(!empty($keyword)){
            $install = [];
            foreach($keyword AS $key => $value)
                if(!empty($value))$install[]['keyword'] = $value;
            keyword::where('id','>',1)->delete(true);
            (new keyword())->saveAll($install);
        }
        $list = keyword::select();
        return $this->view('/admin/monitor/keyword',['list' => $list]);
    }

    public function website(){
        $website = input('website');
        if(!empty($website)){
            $install = [];
            foreach($website['name'] AS $key => $value)
                if(!empty($value['name']))$install[$key]['name'] = $value;
            foreach($website['website'] AS $key => $value)
                if(!empty($value['website']))$install[$key]['website'] = $value;
            if(!empty($install)){
                cache('website',$install);
            }
        }
        $list = cache('website');
        return $this->view('/admin/monitor/website',['list' => $list]);
    }
    public function monitor(){
        $post = input('post.');
        if(!empty($post))cache('monitor',$post);
        $info = cache('monitor');
        return $this->view('/admin/monitor/monitor',['info' => $info]);
    }
}